# -*- coding: utf-8 -*-
import scrapy
from meizitu.items import MeizituItem

class FuliSpider(scrapy.Spider):
    name = 'fuli'
    allowed_domains = ['www.meizitu.com']
    start_urls = ['http://www.meizitu.com/a/fuli.html']

    def parse(self, response):
        for sel in response.xpath('//ul[@class="wp-list clearfix"]/li'):
            link = sel.xpath('div/div/a/@href').extract_first()

            yield scrapy.Request(link, self.getdetail)
    
    def getdetail(self, response):
        item = MeizituItem()
        item['name'] = response.xpath('//div[@class="metaRight"]/h2/a/text()').extract_first()
        item['image_urls'] = response.xpath('//div[@id="picture"]/p/img/@src').extract()
        yield item
        